' ***^^^***|||***^^^***
' 
'  This file is regenerated until it's edited. Delete the file to force regeneration.

'  NOTE: This denotes the way the file was created and it's possible the 
'        generation type has since changed.
'        Check the generation script for the curent state of the file.

' %%%###%%%89b082ad17761ee87640d423ac02110e%%%###%%%
' %%%##NoWS##%%%c9d3964e60144266a8eb116eebde204f%%%##NoWS##%%%
' ***^^^***|||***^^^***

  
'************************************************************************************
' Copyright © 2003-2006 Kathleen Dollard
'
' This software is provided 'as-is', without any express or implied warranty. In no 
' event will the author be held liable for any damages arising from the use of this
' software.
' 
' You may use this software for any purpose, including commercial applications, 
' and you may redistribute this software as part of application delivery: however, 
' this copyright notice may not be removed and you may not otherwise redistribute 
' this software directly other than providing a link to wwww.gendotnet.com. 
'
' You may alter this software to better server your needs (I'd like to hear about your 
' changes in order to make the software better). If you alter the softwre, you must  
' clearly mark it as altered and must not be misrepresented as the original software.
' nor wholly your original work.
'*************************************************************************************

Option Explicit On
Option Strict On

Imports System
Imports System.Collections.Generic



Public Class MapMapping
   Public Function GetObjectDef(ByVal name As String) As MapObjectDef
      For Each objectDef As MapObjectDef In Me.MapObjectDefs
         If objectDef.Name = name Then
            Return objectDef
         End If
      Next
      For Each objectDef As MapObjectDef In Me.MapObjectDefs
         If objectDef.TableName = name Then
            Return objectDef
         End If
      Next
      Return Nothing
   End Function

   Public Function AppearsAsChild(ByVal objectDef As MapObjectDef) As Boolean
      For Each testObjectdef As MapObjectDef In Me.MapObjectDefs
         If testObjectdef.HasThisChild(objectDef) Then
            Return True
         End If
      Next
      Return False
   End Function

   Public Function GetChild( _
               ByVal objectDef As MapObjectDef, _
               ByVal fKey As MapForeignKey) _
               As MapChild
      If fKey.MapRelationKeys.Count = 0 Then
         Return Nothing
      End If
      Dim parentObject As MapObjectDef = objectDef.MapMapping.GetObjectDef(fKey.MapRelationKeys(0).ParentObject)
      If parentObject Is Nothing Then
         Return Nothing
      End If
      For Each child As MapChild In parentObject.MapChildren
         If child.MapChildObjectDef Is objectDef Then
            Dim match As Boolean = child.MapRelationKeys.Count = fKey.MapRelationKeys.Count
            If match Then
               For i As Int32 = 0 To child.MapRelationKeys.Count - 1
                  If child.MapRelationKeys(i).ChildColumn <> fKey.MapRelationKeys(i).ChildColumn Then
                     match = False
                     Exit For
                  End If
               Next
            End If
            If match Then
               Return child
            End If
         End If
      Next
      Return Nothing
   End Function
End Class

Public Class MapMappingCollection

End Class 

